<!--  -->
<template>
  <div>
    <van-field
      class="register_field"
      type="digit"
      left-icon="http://q5o9rl630.bkt.clouddn.com/register_code_icon.png"
      v-model="registerForm.code"
      center
      clearable
      maxlength="6"
      placeholder="请输入短信验证码"
    >
      <van-button
        v-if="showCodeBtn"
        slot="button"
        color="#588135"
        size="small"
        type="primary"
        @click="get_code"
      >{{codeTxt}}</van-button>
      <van-button
        v-if="!showCodeBtn"
        slot="button"
        color="#588135"
        size="small"
        type="primary"
        :disabled="true"
      >{{second}}</van-button>
    </van-field>
  </div>
</template>

<script>
export default {
  data() {
    return { showCodeBtn: true, second: 60, codeTxt: "点击发送验证码" };
  },
  props: {
    navTitle: { type: String, default: "" },
    right: { type: Boolean, default: true }
  },
  created() {},
  mounted() {},
  methods: {
    timeDown() {
      let result = setInterval(() => {
        --this.second;
        if (this.second < 0) {
          clearInterval(result);
          this.second = 60;
          this.showCodeBtn = true;
          this.txt = "重新获取";
        }
      }, 1000);
    },
    get_code() {}
  }
};
</script>

<style scoped>
</style>
